<title>Operator Precedence</title>
<head>

</head>

<body bgcolor="#ffffcc">
<hr>
<center><h1>Operator Precedence</h1></center>
<hr>


The following tables show the order in which operators are evaluated. 
Please note the following.

<ul>
<li>The order in which the operands are evaluated is not specified in
the ANSII standard.

<li>For readability you should not rely on these rules! Put everything
in brackets so you intension is clear to the compiler and other 
programmers.
</ul>

<dl compact>

<dt><img src="../../GRAPHICS/whiteball.gif" width=26 height=14 alt="o" name="summary">
<a href="#summary">Summary table.</a>

<dt><img src="../../GRAPHICS/whiteball.gif" width=26 height=14 alt="o" name="detail">
<a href="#detail">Table in detail.</a>
                   
<dt><img src="../../GRAPHICS/whiteball.gif" width=26 height=14 alt="o" name="ops">
<a href="expressions.html">Operators listed by type.</a>
</dl>

<hr>

<a name=summary>
<h2>Summary precedence table.</h2>

All operators on the same line have the same precedence.
The first line has the highest precedence.
<p>
<center>
<table border=1 center=4 bgcolor=ivory bgcolor=ivory>

<tr align=center><td> () </td><td> [] </td><td> -> </td><td> .  </td></tr>
<tr align=center><td> !  </td><td> ~  </td><td> ++ </td><td> -- </td><td> + </td>
                 <td> -  </td><td> *  </td><td> &  </td><td> sizeof </td> </tr>
<tr align=center><td> *  </td><td> /  </td><td> %  </td></tr>
<tr align=center><td> +  </td><td> -  </td></tr>
<tr align=center><td> << </td><td> >> </td></tr>
<tr align=center><td> <  </td><td> <= </td><td> >= </td><td> >  </td></tr>
<tr align=center><td> == </td><td> != </td></tr>
<tr align=center><td> &  </td></tr>
<tr align=center><td> ^  </td></tr>
<tr align=center><td> |  </td></tr>
<tr align=center><td> && </td></tr>
<tr align=center><td> || </td></tr>
<tr align=center><td> ?: </td></tr>
<tr align=center><td> =  </td><td> += </td><td> -= </td><td> *= </td><td> /= </td>
                 <td> %= </td><td> &= </td><td> ^= </td><td> |= </td><td> <<= </td>
                 <td> >>= </td></tr> 
<tr align=center><td> ,  </td></tr>
</table>
</center>
<p>
<i>
Lary Huang has told me that the </i><b>postfix unary --</b><i> and
</i><b>postfix unary ++</b><i> have a
higher precedence than the </i><b>prefix unary --</b><i> and
</i><b>prefix unary ++</b><i>.
</i>
<hr>

<a name=detail>
<h2>Detailed precedence table.</h2>

All operators in the same 'block' have the same precedence. The first block 
has the 
highest precedence.
<p>

<center>
<table border=1 bgcolor=ivory>
<th>Group</th><th>Operator</th><th>Description</th><th>Example</th>
<tr>
<td>
Membership.
</td>
</tr>

<tr align=center>
<td></td><td>()</td><td><a href="../SYNTAX/functions.html">Function call.</a></td><td>count = function(4,3);</td>
</tr>

<tr align=center>
<td></td><td>[]</td><td><a href="arrays.html">Array.</a></td><td>value = array[5] + increment;</td>
</tr>

<tr align=center>
<td></td><td>-></td><td><a href="../SYNTAX/struct.html#pointers">Structure pointer.</a></td>
</tr>

<tr align=center>
<td></td><td> .</td><td><a href="../SYNTAX/struct.html#membership">Structure member.</a></td>
</tr>

<tr align=center>
<td>
Unary.
</td>
</tr>

<tr align=center>
<td></td><td>!</td><td><a href="../SYNTAX/logical.html#NOT">Logical NOT</a></td>
</tr>

<tr align=center>
<td></td><td>~   </td><td>	</td>
</tr>

<tr align=center>
<td></td><td>++</td><td><a href="inc_dec.html">Increment.</a></td>
</tr>

<tr align=center>
<td></td><td>--</td><td><a href="inc_dec.html">Decrement.</a></td>
</tr>

<tr align=center>
<td></td><td>+ </td><td></td>
</tr>

<tr align=center>
<td></td><td>-  </td>
</tr>

<tr align=center>
<td></td><td>*</td><td><a href="../EXAMPLES/address.c">Pointer to data</a></td>
</tr>

<tr align=center>
<td></td><td>&</td><td><a href="../EXAMPLES/address.c">Address of a variable.</a></td>
</tr>

<tr align=center>
<td></td><td>sizeof</td>
</tr>

<tr align=center>
<td></td><td>(type)</td><td><a href="cast.html">type cast.</a></td>
</tr>

<tr align=center>
<td>
Binary.
</td>

<tr align=center>
<td></td><td>* </td><td>Multiply.</td>
</tr>

<tr align=center>
<td></td><td>/ </td><td>Divide.</td>
</tr>

<tr align=center>
<td></td><td>% </td><td><a href="../EXAMPLES/modulo.c">Modulo.</a></td>
</tr>

<tr align=center>
<td>
Binary.
</td>
</tr>

<tr align=center>
<td></td><td>+ </td><td>Addition</td>
</tr>

<tr align=center>
<td></td><td>- </td><td>Subtraction.</td>
</tr>

<tr align=center>
<td>
Bitwise
</td>
</tr>

<tr align=center>
<td></td><td><<	</td><td><a href="bit_shift.html">Shift left.</a></td>
</tr>

<tr align=center>
<td></td><td>>>	</td><td><a href="bit_shift.html">Shift Right.</a></td>
</tr>

<tr align=center>
<td>
Relational.
</td>
</tr>

<tr align=center>	
<td></td><td><	</td><td>Less than.</td>
</tr>

<tr align=center>
<td></td><td>>	</td><td>Greater than.</td>
</tr>

<tr align=center>
<td></td><td><=	</td><td>Less than or equal too.</td>
</tr>

<tr align=center>
<td></td><td>>=	</td><td>Greater than or equal too.</td>
</tr>

<tr align=center>
<td></td><td>==	</td><td>Equal too.</td>
</tr>

<tr align=center>
<td></td><td>!=	</td><td>Not equal too.</td>
</tr>

<tr align=center>
<td>
More Bitwise
</td>
</tr>

<tr align=center>
<td></td><td>&	</td><td><a href="../CONCEPT/bitwise.html">bitwise AND</a></td>
</tr>

<tr align=center>
<td></td><td>^  </td><td><a href="../CONCEPT/bitwise.html">bitwise Excusive OR</a></td>
</tr>

<tr align=center>
<td></td><td>|	</td><td><a href="../CONCEPT/bitwise.html">bitwise OR</a></td>
</tr>

<tr align=center>
<td>
Logical.	
</td>
</tr>

<tr align=center>
<td></td><td>&&	</td><td><a href="../SYNTAX/logical.html#AND">Logical AND</a></td>
</tr>

<tr align=center>
<td>
Logical.	
</td>
</tr>

<tr align=center>
<td></td><td>||	</td><td><a href="../SYNTAX/logical.html#OR">Logical OR</a></td>
</tr>
<tr align=center>
<td>
Conditional
</td>
</tr>

<tr align=center>
<td></td><td>? : </td><td><a href="../SYNTAX/conditional.html">Conditional construct.</a></td>
</tr>

<tr align=center>
<td>
Assignment
</td>
</tr>

<tr align=center>
<td></td><td>=	 </td><td><a href="assignment.html">Equals</a></td>
</tr>

<tr align=center>
<td></td><td>+=	 </td><td><a href="assignment.html">assignment</a></td>
</tr>

<tr align=center>
<td></td><td>-=	 </td><td><a href="assignment.html">assignment</a></td>
</tr>

<tr align=center>
<td></td><td>*=	 </td><td><a href="assignment.html">assignment</a></td>
</tr>

<tr align=center>
<td></td><td>/=	 </td><td><a href="assignment.html">assignment</a></td>
</tr>

<tr align=center>
<td></td><td>%=	 </td><td><a href="assignment.html">assignment</a></td>
</tr>

<tr align=center>
<td></td><td>&=	 </td><td><a href="assignment.html">assignment</a></td>
</tr>

<tr align=center>
<td></td><td>^=	 </td><td><a href="assignment.html">assignment</a></td>
</tr>

<tr align=center>
<td></td><td>|=	 </td><td><a href="assignment.html">assignment</a></td>
</tr>

<tr align=center>
<td></td><td><<= </td><td><a href="assignment.html">assignment</a></td>
</tr>

<tr align=center>
<td></td><td>>>= </td><td><a href="assignment.html">assignment</a></td>
</tr>

<tr align=center>
<td>
Series
</td>
</tr>

<tr align=center>
<td></td><td>,   </td><td><a href="../SYNTAX/comma.html">Comma</a></td>
</tr>
</table>
</center>

<p>
<hr>
<h2>See also:</h2>

<img src="../../GRAPHICS/whiteball.gif" width=26 height=14 alt="o" name="exp">
<a href="expressions.html#bit">Expressions and operators.</a>
<br>
<img src="../../GRAPHICS/whiteball.gif" width=26 height=14 alt="o" name="ass">
<a href="../CONCEPT/assignment.html">Assignment Operators.</a>
<br>


<p>

<hr>
<p>
<center>
<table border=2 width="80%" bgcolor="ivory">
<tr align=center>
<td width="25%">
<a href="../cref.html">                  Top</a>
</td><td width="25%">
<a href="../master_index.html">          Master Index</a>
</td><td width="25%">
<a href="../SYNTAX/keywords.html">                 Keywords</a>
</td><td width="25%">
<a href="../FUNCTIONS/funcref.htm">      Functions</a>
</td>
</tr>
</table>
</center>
<p>
<hr>
<address><a href="../../address.html">Martin Leslie</a> 
</address><p>
</body>
</html>

